<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="css/style.css" />
<link type="text/css" rel="stylesheet" href="../css/style.css" />
<title>Admin control panel !</title>
</head>

<body>
<?php include("menu.php"); 
include("session.php");
include("../include/config.php");
?>


<div id="head-noidung">
	<div id="head-main">
	<?php 
		$sql="SELECT * FROM setting WHERE id=1";
		$rs=mysql_query($sql);
		if($rs) 
		{
			$row=mysql_fetch_array($rs);
		}
		else
		{
			$sql= "INSERT INTO setting VALUES (1, 'My Website', 'My URL','Phone Number', 'My video', 'My address','support@gmail.com', 'My notice')";
			mysql_query($sql);
			$page = $_SERVER['PHP_SELF'];
			$sec = 0;
			header("Refresh: $sec; url=$page");
		}
	 ?>	
	 <h2 align="center">Cấu Hình Website</h2>
	 <form action="" method="post">
	<table>
	<tr><td>Tên Website:</td>
	<td><input name="title" class="txt" type="text" value="<?php echo stripslashes($row['title'])?>"/></td>
	</tr>
	<tr>
		<td>Địa chỉ Website:</td>
		<td><input type="text" class="txt" name="url"  value="<?php echo stripslashes($row['url'])?>"/></td>
	</tr>	
	<tr>
	<td>Địa chỉ công ty:</td>	
	<td><input type="text" class="txt" name="address"  value="<?php echo stripslashes($row['address'])?>"/></td>
		</tr>
	<tr>
	<tr>
	<td>Số ĐT:</td>	
	<td><input type="text" class="txt" name="phone"  value="<?php echo stripslashes($row['phone'])?>"/></td>
		</tr>
	<tr>
	<td>Youtube Video URL:</td>
	<td><input type="text" class="txt" name="video"  value="<?php echo stripslashes($row['video'])?>"/></td>

	<tr>
	<td>Email Hỗ trợ:</td>
	<td><input type="text" class="txt" name="mailsupport"  value="<?php echo stripslashes($row['mailsupport'])?>"/></td>
	</tr>

	</tr>
	<tr><td>Thông báo:</td>
	<td><textarea name="notice" class="txt" rows="10"><?php echo stripslashes($row['notice'])?></textarea></td>
	</tr>
	<tr>
	<td></td>
	<td align="center"><input type="submit" name="update" value="Cập nhật"/></td>
	</tr>
	
	</table>	
	</form>
		
	</div>	
</div>
<?php include("images/cherry/footer.php"); ?>

</body>
</html>
<?php 
	if (isset($_REQUEST["update"]))
	{
		$title	=	htmlspecialchars(mysql_real_escape_string($_POST['title']));
		$url	=	htmlspecialchars(mysql_real_escape_string($_POST['url']));
		$address=	htmlspecialchars(mysql_real_escape_string($_POST['address']));
		$video 	=	htmlspecialchars(mysql_real_escape_string($_POST['video']));
		$mailsupport	=	htmlspecialchars(mysql_real_escape_string($_POST['mailsupport']));
		$notice	=	htmlspecialchars(mysql_real_escape_string($_POST['notice']));
		$phone = htmlspecialchars(mysql_real_escape_string($_POST['phone']));
		$sql="UPDATE setting SET title='$title',url='$url',address='$address',video='$video',mailsupport='$mailsupport',notice='$notice',phone='$phone' WHERE id=1";
		mysql_query($sql);
		$page = $_SERVER['PHP_SELF'];
		header("Location: $page");
	}
?>